package hongcaosp.app.android.video.online.presenter;

import hongcaosp.app.android.login.UserToken;
import hongcaosp.app.android.modle.DataCallBack;
import hongcaosp.app.android.modle.impl.OnlineModelImpl;
import hongcaosp.app.android.video.online.bean.OnlineRankWrap;
import hongcaosp.app.android.video.online.iview.IOnlineHomeView;
import xlj.lib.android.base.component.BasePresenter;
import xlj.lib.android.base.toastcompat.ToastManager;

public class OnlineHomePresenter extends BasePresenter {

    private OnlineModelImpl onlineModel;
    private IOnlineHomeView view;

    public OnlineHomePresenter(IOnlineHomeView view) {
        this.view = view;
        this.onlineModel = new OnlineModelImpl();
    }

    public void list() {
        onlineModel.list(UserToken.getDefault().getToken(), new DataCallBack<OnlineRankWrap>() {
            @Override
            public void onGetData(OnlineRankWrap data) {
                super.onGetData(data);
                view.rankData(data.getList());
            }

            @Override
            public void onFail(int code, String errorMessage) {
                super.onFail(code, errorMessage);
                ToastManager.getInstance().showToast(errorMessage);
            }
        });
    }
}
